package com.example.fan.airline_reservation.Custom;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;

import com.example.fan.airline_reservation.R;

public class CreateUserDialog extends Dialog {

    Activity context;
    private Button next;
    private EditText money;

    private View.OnClickListener mClickListener;

    public CreateUserDialog(Activity context) {
        super(context,R.style.MyDialog);
        this.context = context;
    }

    public CreateUserDialog(Activity context, int theme, View.OnClickListener clickListener) {
        super(context, R.style.MyDialog);
        this.context = context;
        this.mClickListener = clickListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        this.setContentView(R.layout.recharge_dialog);

        money=(EditText)findViewById(R.id.money);

        /*
         * 获取圣诞框的窗口对象及参数对象以修改对话框的布局设置, 可以直接调用getWindow(),表示获得这个Activity的Window
         * 对象,这样这可以以同样的方式改变这个Activity的属性.
         */
        Window dialogWindow = this.getWindow();

        WindowManager m = context.getWindowManager();
        Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
        WindowManager.LayoutParams p = dialogWindow.getAttributes(); // 获取对话框当前的参数值
        /*p.height = (int) (d.getHeight() * 0.6); // 高度设置为屏幕的0.6*/
        p.width = (int) (d.getWidth() * 0.8); // 宽度设置为屏幕的0.8
        dialogWindow.setAttributes(p);

        next=(Button)findViewById(R.id.next);
        next.setOnClickListener(mClickListener);

        this.setCancelable(true);
    }

    public EditText getMoney() {
        return money;
    }

    public void setMoney(EditText money) {
        this.money = money;
    }
}
